using System;
using System.Text;
using Anthem;


namespace UsrControls
{




        public class PopupPanel : Panel
        {
            // Methods
            public void Hide()
            {
                Manager.AddScriptForClientSideEval("undimbody();");
                this.IsHide = true;
                this.Visible = false;
                this.UpdateAfterCallBack = true;
            }

            protected override void OnLoad(EventArgs e)
            {
                if (!this.Page.IsPostBack)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("color: #333;");
                    builder.Append("display: none;");
                    builder.Append("position: absolute; ");
                    builder.Append("top: 25%;");
                    builder.Append("left: 25%;");
                    builder.Append("width: " + this.Width.ToString() + " px;");
                    builder.Append("height: " + this.Height.ToString() + "px;");
                    builder.Append("padding: 1em;");
                    builder.Append("border: 1em solid #B8B8B8; ");
                    builder.Append("background-color: white;");
                    builder.Append("text-align: left;");
                    builder.Append("z-index:1002;");
                    builder.Append("overflow: auto;");
                    base.Attributes["style"] = builder.ToString();
                }
                StringBuilder builder2 = new StringBuilder();
                builder2.Append("<style>");
                builder2.Append("#overlay{");
                builder2.Append("display:none;");
                builder2.Append("position:absolute;");
                builder2.Append("top:0;");
                builder2.Append("left:0;");
                builder2.Append("z-index:1001;");
                builder2.Append("background-color:#333;");
                builder2.Append("-moz-opacity: 0.8;");
                builder2.Append("opacity:.80;");
                builder2.Append("filter: alpha(opacity=80);");
                builder2.Append("} </style> ");
                builder2.Append("<style>");
                builder2.Append("#popupFrame{");
                builder2.Append("position:absolute;");
                builder2.Append("top:0;");
                builder2.Append("left:0;");
                builder2.Append("z-index:1000;");
                builder2.Append("background-color:#333;");
                builder2.Append("filter: alpha(style=0,opacity=0)';");
                builder2.Append("} </style> ");
                builder2.Append("<div style='display: none;' id='overlay'>");
                builder2.Append("<iframe src='#' id='popupFrame'>");
                builder2.Append("</iframe>");
                builder2.Append("</div>");
                builder2.Append("<script language='javascript'>");
                builder2.Append("function dimbody() {");
                builder2.Append("var winW = 0, winH = 0;");
                builder2.Append("var x=document.getElementById('overlay');");
                builder2.Append("var xiframe=document.getElementById('popupFrame');");
                builder2.Append("if (parseInt(navigator.appVersion)>3) {");
                builder2.Append("if (navigator.appName=='Netscape') {");
                builder2.Append("winW = window.innerWidth + window.scrollMaxX;");
                builder2.Append("winH = window.innerHeight + window.scrollMaxY; }");
                builder2.Append("if (navigator.appName.indexOf('Microsoft')!=-1) {");
                builder2.Append("if (document.body.offsetWidth >= document.body.scrollWidth) {");
                builder2.Append("winW = document.body.offsetWidth + 20;");
                builder2.Append("}else{");
                builder2.Append("winW = document.body.scrollWidth;");
                builder2.Append("}");
                builder2.Append("if (document.body.offsetHeight >= document.body.scrollHeight) {");
                builder2.Append("winH = document.body.offsetHeight + 20;");
                builder2.Append("}else{");
                builder2.Append("winH = document.body.scrollHeight;");
                builder2.Append("}");
                builder2.Append("}}");
                builder2.Append("x.style.width = winW;");
                builder2.Append("x.style.height = winH;");
                builder2.Append("x.style.display='block'; ");
                builder2.Append("if (navigator.appName.indexOf('Microsoft')!=-1) {");
                builder2.Append("xiframe.style.width = winW;");
                builder2.Append("xiframe.style.height = winH;");
                builder2.Append("}else{");
                builder2.Append("xiframe.style.width = 0;");
                builder2.Append("xiframe.style.height = 0;");
                builder2.Append("xiframe.style.display='none'; ");
                builder2.Append("}");
                builder2.Append("}");
                builder2.Append("function undimbody() {");
                builder2.Append("var x=document.getElementById('overlay');");
                builder2.Append("x.style.display='none';");
                builder2.Append("}</script>");
                builder2.Append("");
                builder2.Append("");
                builder2.Append("");
                this.Page.RegisterStartupScript("startup", builder2.ToString());
                base.OnLoad(e);
            }

            public void Show()
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("color: #333;");
                builder.Append("display:;");
                builder.Append("position: absolute; ");
                builder.Append("top: 25%;");
                builder.Append("left: 25%;");
                builder.Append("width: " + this.Width.ToString() + " px;");
                builder.Append("height: " + this.Height.ToString() + "px;");
                builder.Append("padding: 1em;");
                builder.Append("border: 1em solid #B8B8B8; ");
                builder.Append("background-color: white;");
                builder.Append("text-align: left;");
                builder.Append("z-index:1002;");
                builder.Append("overflow: auto;");
                base.Attributes["style"] = builder.ToString();
                Manager.AddScriptForClientSideEval("dimbody();");
                this.IsHide = false;
                this.Visible = true;
                this.UpdateAfterCallBack = true;
            }

            // Properties
            protected bool IsHide
            {
                get
                {
                    if (this.ViewState["IsHide"] != null)
                    {
                        return Convert.ToBoolean(this.ViewState["IsHide"]);
                    }
                    return true;
                }
                set
                {
                    this.ViewState["IsHide"] = value;
                }
            }
        }






    }
